home *** CD-ROM | disk | FTP | other *** search
-
- // Main program for testing the Stack object
-
- //SOLUTION
-
- #import <stdio.h>
- #import "RPNCalculator.h"
-
- main ( argc, argv )
- int argc;
- char *argv[];
- {
- id calc;
-
- printf("\nCreate an RPNCalculator instance...\n");
- calc = [[RPNCalculator alloc] init]; //allocate and initialize
-
- printf("Enter numbers 5.0, -10.0, -20.0, and 15.0 ...\n");; // and print the stack
- [calc enter:5.0];
- [calc enter:-10.0];
- [calc enter:-20.0];
- [calc enter:15.0];
- [calc printStack];
-
- printf("Add...\n");; // and print the stack
- [calc add];
- [calc printStack];
-
- printf("Subtract...\n");; // and print the stack
- [calc subtract];
- [calc printStack];
-
- printf("Clear the calculator's stack...\n");; // and print the stack
- [calc allClear];
- [calc printStack];
-
- printf("Free the calculator and its stack...\n");
- [calc free];
- } // end of program
-